<script type="text/javascript" src="image/weather/weather.js"></script>

<script type="text/javascript">
 
  function getRate(from, to) {
    var script = document.createElement('script');
    script.setAttribute('src', "http://query.yahooapis.com/v1/public/yql?q=select%20rate%2Cname%20from%20csv%20where%20url%3D'http%3A%2F%2Fdownload.finance.yahoo.com%2Fd%2Fquotes%3Fs%3D"+from+to+"%253DX%26f%3Dl1n'%20and%20columns%3D'rate%2Cname'&format=json&callback=parseExchangeRate");
    document.body.appendChild(script);
  }
 
  function parseExchangeRate(data) {
	 var name = data.query.results.row.name.substring(0,3);
	 var html = '<tbody>'
	  $.each(data,function(key,val) {
		  var res = parseFloat(data.query.results.row.rate).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,');
		  res = res.substring(0, res.indexOf('.'));
		  html += '<tr><td>'
				+ currencies[name]
				+ '</td><td>'
				+ res
				+ '</td></tr>';
	});
	 html += '</tbody>';
	 $('#currency-widget').append(html);
  }
  var currencies = new Array();
  $( document ).ready(function() {
	  currencies['USD'] = 'Đô la Mỹ';
	  currencies['GBP'] = 'Bảng Anh';
	  currencies['EUR'] = 'Euro';
	  currencies['CNY'] = 'Nhân dân tệ';
	  currencies['HKD'] = 'Đô la HK';
	  currencies['JPY'] = 'Yên';
	  currencies['THB'] = 'Bạt';
	  currencies['SGD'] = 'Đô la Sing';
	  for (var k in currencies){
		if (currencies.hasOwnProperty(k)) {
			getRate(k, "VND");
		}
	  }
});
</script>

<div id="load_div"></div>
<div class="box">
	<div class="box-heading-weather"></div>
	<div class="box-heading"><?php echo $heading_title; ?></div>
	<div class="box-content" style="text-align: center;">
		<iframe id="main-weather-widget" frameborder="0" marginwidth="0"
			marginheight="0"
			src="http://muasamcangay.com/tool/weather/?size=160&fsize=12&bg=images/bg.png&repeat=repeat-x&r=1&w=1&g=1&col=1&d=3"
			height="210" width="160" scrolling="no"></iframe>
		<table id="currency-widget">
			<tbody>
				<tr>
					<td>Loại ngoại tệ</td>
					<td>Bán</td>
				</tr>
			</tbody>
		</table>
	</div>
</div>
<style>
#currency-widget {
	border-top: 1px solid #ccc;
	border-left: 1px solid #ccc;
	margin-left: 9px;
	width: 152px;
	border-collapse: collapse;
}

#currency-widget tbody tr td {
	border-bottom: 1px solid #ccc;
	border-right: 1px solid #ccc;
	padding: 0;
}

#currency-widget tbody tr td:first-child {
	text-align: left;
}

#currency-widget tbody tr td:last-child {
	text-align: right;
}
</style>